package com.group.model;

import java.util.Calendar;
import java.util.Date;

/**
 * 小说投资记录
 * 
 * @author zhaolei
 *
 */
public class BookInvestLog {

	private Long id;

	private Long userId;

	private Long bookId;
	
	private Book book;

	/**
	 * 已投资小说金额
	 */
	private Double amountTotal;

	/**
	 * 小说名
	 */
	private String name;

	/**
	 * 投资数量
	 */
	private Double amount;

	/**
	 * 投资期限 月
	 */
	private Integer investMonth;
	
	/**
	 * 是否到期, 0 否 1 是
	 */
	private Integer state;

	/**
	 * 小说类型
	 */
	private Integer type;

	/**
	 * 权重
	 */
	private Double weight;

	/**
	 * 开始时间
	 */
	private Date startTime;

	/**
	 * 结束时间
	 */
	private Date endTime;
	
	/**
	 * 投资收益
	 */
	private Double profit;

	private Date createTime;

	/**
	 * 年化收益率
	 */
	private Double yearProfit;

	/**
	 * 头像
	 */
	private String headimage;

	/**
	 * 姓名,昵称
	 */
	private String userName;

	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	public Double getYearProfit() {
		return yearProfit;
	}

	public void setYearProfit(Double yearProfit) {
		this.yearProfit = yearProfit;
	}

	/**
	 * 初始化 时间和权重
	 */
	public void init() {
		if (investMonth != null) {
			if (investMonth == 3)
				weight = 1.0;
			if (investMonth == 6)
				weight = 1.1;
			if (investMonth == 12)
				weight = 1.3;

			// 起始时间
			Calendar cal = Calendar.getInstance();
			startTime = cal.getTime();

			cal.add(Calendar.MONTH, investMonth);
			cal.set(Calendar.HOUR_OF_DAY, 23);

			endTime = cal.getTime();

		}
	}

	public Double getAmountTotal() {
		return amountTotal;
	}

	public void setAmountTotal(Double amountTotal) {
		this.amountTotal = amountTotal;
	}

	public String getHeadimage() {
		return headimage;
	}

	public void setHeadimage(String headimage) {
		this.headimage = headimage;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public Long getBookId() {
		return bookId;
	}

	public void setBookId(Long bookId) {
		this.bookId = bookId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Double getAmount() {
		return amount;
	}

	public void setAmount(Double amount) {
		this.amount = amount;
	}

	public Integer getInvestMonth() {
		return investMonth;
	}

	public void setInvestMonth(Integer investMonth) {
		this.investMonth = investMonth;
	}

	public Double getWeight() {
		return weight;
	}

	public void setWeight(Double weight) {
		this.weight = weight;
	}

	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Integer getState() {
		return state;
	}

	public void setState(Integer state) {
		this.state = state;
	}

	public Double getProfit() {
		return profit;
	}

	public void setProfit(Double profit) {
		this.profit = profit;
	}

	public Book getBook() {
		return book;
	}

	public void setBook(Book book) {
		this.book = book;
	}

}
